package com.java.pertar.springtest;


import org.springframework.util.AutoPopulatingList;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/massage")
public class Demo1 {

    private List<Demo2> list = new ArrayList<Demo2>();

    @RequestMapping(value = "/publish", produces = "application/json")
    public String publish(@RequestBody Demo2 demo) {
        if (!StringUtils.hasLength(demo.getFrom()) || !StringUtils.hasLength(demo.getTo()) || !StringUtils.hasLength(demo.getSay())) {
            return "{\"ok\": 0}";
        }


        list.add(demo);
        return "{\"ok\": 1}";

    }

    @RequestMapping("/getList")
    public List<Demo2> aa() {
        return list;



    }

}
